#ifndef TRI_FRACTAL_H
#define TRI_FRACTAL_H

#include "Demo.h"
#include "VectorBatch.h"
#include "RenderTarget.h"

using namespace Cvekas;

class TriFractal : public TimelineSegment
{
public:
	TriFractal(RendererPtr renderer, VectorBatchPtr vector_batch, SpriteBatchPtr sprite_batch);
	virtual ~TriFractal();

	virtual void init(boost::weak_ptr<Demo> owner);
	virtual void close();
	
	virtual void update(float t);
	virtual void render(float t);
	
protected:
	void drawFractal(const Vector2& pos, float distance, float distance_ratio, 
		float size, float size_ratio, float rotation, float delta_rotation, int depth);

	Vector2 fractal_position;
	float fractal_distance;
	float fractal_distance_ratio;
	float fractal_size;
	float fractal_size_ratio;
	float fractal_rotation;
	float fractal_delta_rotation;
	int fractal_depth;

private:
	VectorBatchPtr vector_batch;
	SpriteBatchPtr sprite_batch;
	RenderTargetPtr offscreen_target1;
	RenderTargetPtr offscreen_target2;
	RendererPtr renderer;
};

typedef boost::shared_ptr<TriFractal> TriFractalPtr;

#endif